package com.itheima.sh.user.service;

import com.itheima.sh.pojo.User;
import com.itheima.sh.user.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j  //lombok提供的 打印日志注解
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User queryById(String username) {

        //模拟异常
      // int i=1/0;

               /* try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
       log.error("这是一个错误");
        }
*/
        if (username.equals("itheima")){
            throw new RuntimeException("itheima");

        }

        return userMapper.findById(username);
    }
}
